import { createRouter, createWebHistory } from 'vue-router'
import loginView from '../views/loginView.vue'
// 挂号相关的页面导入
import regHome from '../views/regHome.vue'
import winRegist from '../components/regist/winRegist.vue'
import winUnRegist from '../components/regist/winUnRegist.vue'
import payMoney from '../components/regist/payMoney.vue'
import backMoney from '../components/regist/backMoney.vue'
import searchPayment from '../components/regist/searchPayment.vue'
import magHome from '../views/magHome.vue'
// 管理员相关的页面导入
import deptView from '../components/manage/deptView.vue'
import docView from '../components/manage/docView.vue'
import drugView from '../components/manage/drugView.vue'
import levelView from '../components/manage/levelView.vue'
import prescriptionView from '../components/manage/prescriptionView.vue'
import regView from '../components/manage/regView.vue'
import schView from '../components/manage/schView.vue'


// import HomeView from '../views/HomeView.vue';
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'loginView',
      component: loginView,
      
    },
    {
      path:'/regHome',
      name:'regHome',
      component:regHome,
      children:[
        {
        path:'/winRegist',
        name:'winRegist',
        component:winRegist
      },
      {
        path:'/winUnRegist',
        name:'winUnRegist',
        component:winUnRegist
      },
      {
        path:'/payMoney',
        name:'payMoney',
        component:payMoney
      },
      {
        path:'/backMoney',
        name:'backMoney',
        component:backMoney
      },
      {
        path:'/searchPayment',
        name:'searchPayment',
        component:searchPayment
      },
    ]
    },
    {
      path:'/magHome',
      name:'magHome',
      component:magHome,
      children:[
        {
          path:'/deptView',
          name:'deptView',
          component:deptView
        },
        {
          path:'/docView',
          name:'docView',
          component:docView
        },
        {
          path:'/drugView',
          name:'drugView',
          component:drugView
        },
        {
          path:'/levelView',
          name:'levelView',
          component:levelView
        },
        {
          path:'/prescriptionView',
          name:'prescriptionView',
          component:prescriptionView
        },
        {
          path:'/regView',
          name:'regView',
          component:regView
        },
        {
          path:'/schView',
          name:'schView',
          component:schView
        },
      ],
    },


    
    {
      path: '/login',
      name: 'login',
      component:loginView,
      
    },
    {
      path: '/test1',
      name: 'test2',

      component: () => import('../components/test/slipLogin.vue')
    },
    {
      path: '/emp1',
      name: 'emp1',

      component: () => import('../components/dept/DeptView.vue')
    },


  ]
})
/**
 * to是新地址
 * from是旧地址
 */
router.beforeEach((to,from) => {
  //取消导航，不进入不该进的
  // return false;
  //放弃拦截
  // return true;
  console.log("to",to);
  console.log("path",from);
  // const openpaths=['login','reg','resetpassword'];
  // if(openpaths.includes(to.path)){
  //   return "/login";
  // }
  // else{
  //   return "/login";
  // }

})



export default router
